package com.plian.system.service.pf.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pf.LeadershipPayRecordDetail;
import com.plian.system.mapper.pf.LeadershipPayRecordDetailMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.pf.ILeadershipPayRecordDetailService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: TODO
 * @Author: Take-off
 * @Date: 2023/3/27 10:00 AM
 * @Param
 * @return
 * @Version: 1.0
 **/
@Slf4j
@Service
@AllArgsConstructor
public class LeadershipPayRecordDetailServiceImpl extends BaseServiceImpl<LeadershipPayRecordDetailMapper, LeadershipPayRecordDetail> implements ILeadershipPayRecordDetailService {


    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<LeadershipPayRecordDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(LeadershipPayRecordDetail::getBaseId, ids);
        List<LeadershipPayRecordDetail> payRecordDetails = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(payRecordDetails)){
            return deleteLogic(payRecordDetails.stream().map(LeadershipPayRecordDetail::getId).collect(Collectors.toList()));
        }
        return true;
    }

}
